import pygame
import sys

# 初始化Pygame
pygame.init()

size = width, height = 1000, 800
# 创建指定大小的窗口 Surface
screen = pygame.display.set_mode(size)
# 设置窗口标题
pygame.display.set_caption("Demo")
bg = (0, 0, 0)


font = pygame.font.Font(None, 20)
lineHeight = font.get_linesize()
position = 0

screen.fill(bg)

while True:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            sys.exit()
        screen.blit(font.render(str(event), True, (0, 255, 0)), (0, position))
        position = position + lineHeight
        if position > height:
            position = 0
            screen.fill(bg)
        pygame.display.flip()

    

